package com.newegg.nlp.util.corenlp.zh;

import com.newegg.nlp.util.corenlp.Filter;
import com.newegg.nlp.util.corenlp.Keyword;
import com.newegg.nlp.util.corenlp.Result;
import com.newegg.nlp.util.corenlp.TagHelp;

import edu.stanford.nlp.semgraph.SemanticGraph;
import edu.stanford.nlp.semgraph.SemanticGraphEdge;
import edu.stanford.nlp.simple.Sentence;

public class Filter_dobj implements Filter{

	@Override
	public Result filter(SemanticGraphEdge graphEdge, SemanticGraph graph, Sentence sentence) {
		Result result = new Result();
		if("dobj".equals(graphEdge.getRelation().getShortName())) { //依赖关系
			if(TagHelp.isJJ(graphEdge.getSource().tag()) && TagHelp.isNN(graphEdge.getTarget().tag())) {
				result.addKeyword(new Keyword(graphEdge.getSource().value() + graphEdge.getTarget().value(), graphEdge.getSource().value(), graphEdge.getTarget().value()));
			}
		 }
		return result;
	}

}
